FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["src/App.Host/App.Host.csproj", "App.Host/"]
RUN dotnet restore "App.Host/App.Host.csproj"
COPY . .
WORKDIR "/src/src/App.Host"
RUN dotnet build "App.Host.csproj"  -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "App.Host.csproj" -c Release -o /app/publish 

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "App.Host.dll"]